import * as THREE from 'three';
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
import modifyCityMaterail from "../modify/modifyCityMaterail";
import scene from "../scene";
import AlarmSprite from './alarmSprite';
import Flyline from './flyLine';
import LightRander from './lightRander';
import LightWall from './lightWall';

export default function createCity() {
  const gltfLoader = new GLTFLoader();
  gltfLoader.load("./models/city.glb", (gltf) => {
    gltf.scene.traverse(item => {

      if (item.type == 'Mesh') {
        const cityMaterail = new THREE.MeshBasicMaterial({
          color: new THREE.Color(0x0c0e6f)
        })
        item.material = cityMaterail
        // 这里传整个物体而不是材质
        modifyCityMaterail(item)
      }
    })
    scene.add(gltf.scene);
    // 添加飞线，先生成管道不考虑传值
   /*  const flyLine = new Flyline()
    scene.add(flyLine.mesh)
 */
    // 创建光墙
    /* const lightWall = new LightWall()
    scene.add(lightWall.mesh) */

    // 雷达
    /* const lightRander = new LightRander()
    scene.add(lightRander.mesh) */

    // 警告标识
   /*  const alarmSprite = new AlarmSprite()
    scene.add(alarmSprite.mesh)

    alarmSprite.onClick(function (e) {
      console.log('警告');
      console.log(e);
    }) */
  });
}
